package cn.cas.mango.util.paramCheck;

import cn.cas.mango.dto.param.DetailParam;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@Slf4j
public class DetailParamCheckUtil {
  public static Map<String, Object> checkParam(DetailParam formData) {
    Map<String, Object> map = new HashMap<>();
    String isSuccess = "ok";
    if (formData.getId() == null) {
      isSuccess = "传入参数 id为空，请检查参数";
     log.error(isSuccess);
    }
    if (formData.getCurrentPage() == null) {
      formData.setCurrentPage(1);
    }
    if (formData.getPageSize() == null || formData.getPageSize() <= 0) {
      formData.setCurrentPage(10);
    }
    log.info("Request param:{}", formData);
    map.put("isSuccess", isSuccess);
    map.put("formData", formData);
    return map;
  }
}
